package jiyun.com.yiyanmeng;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jcodecraeer.xrecyclerview.XRecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import bean.Adress;

public class TiJiaoActivity extends AppCompatActivity implements View.OnClickListener {


    private String mName1;
    private String mPhone1;
    private String mAddress;
    private String mDetails;
    private TextView mSite;
    private LinearLayout mLin4;
    private ImageView mBtn;
    private TextView mTvLeft;
    private TextView mImageBack;
    private TextView mTvTitle;
    private RelativeLayout mRl;
    private TextView mName;
    private TextView mPhone;
    private LinearLayout mLin2;
    private RelativeLayout mRe3;
    private XRecyclerView mRecyclerView;
    private TextView mTxtPeisong;
    private TextView mTxt2;
    private EditText mEtContent;
    private TextView mTvShuliang;
    private TextView mTxt3;
    private TextView mTvTotal;
    private TextView mTvTotalMoney;
    private TextView mTvSubmitOrder;
    private LinearLayout mRl3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ti_jiao);
        EventBus.getDefault().register(this);
        initView();
    }

    private void initView() {

        mTvLeft = (TextView) findViewById(R.id.tv_left);
        mImageBack = (TextView) findViewById(R.id.image_back);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mRl = (RelativeLayout) findViewById(R.id.rl);
        mName = (TextView) findViewById(R.id.name);
        mPhone = (TextView) findViewById(R.id.phone);
        mLin2 = (LinearLayout) findViewById(R.id.lin2);
        mRe3 = (RelativeLayout) findViewById(R.id.re3);
        mRecyclerView = (XRecyclerView) findViewById(R.id.recyclerView);
        mTxtPeisong = (TextView) findViewById(R.id.txt_peisong);
        mTxt2 = (TextView) findViewById(R.id.txt2);
        mEtContent = (EditText) findViewById(R.id.et_content);
        mTvShuliang = (TextView) findViewById(R.id.tv_shuliang);
        mTxt3 = (TextView) findViewById(R.id.txt3);
        mTvTotal = (TextView) findViewById(R.id.tv_total);
        mTvTotalMoney = (TextView) findViewById(R.id.tv_total_money);
        mTvSubmitOrder = (TextView) findViewById(R.id.tv_submit_order);
        mRl3 = (LinearLayout) findViewById(R.id.rl3);
        mSite = (TextView) findViewById(R.id.site);
        mLin4 = (LinearLayout) findViewById(R.id.lin4);
        mBtn = (ImageView) findViewById(R.id.btn);
        mImageBack.setOnClickListener(this);
        mBtn.setOnClickListener(this);
    }

    //接收数据
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getMog(Adress adress) {
        mName1 = adress.getName();
        mPhone1 = adress.getPhone();
        mAddress = adress.getAddress();
        mDetails = adress.getDetails();
        mSite = findViewById(R.id.site);
        mName.setText("收件人" + mName1);
        mPhone.setText(mPhone1);
        mSite.setText(mAddress + "" + mDetails);
        Log.i("getMog", "=====" + adress.getPhone());


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.image_back:  //回退
                finish();
                break;
            case R.id.btn:  //跳转到  添加页面
                Intent intent = new Intent(this, SiteActivity.class);
                startActivity(intent);
                break;
        }
    }

}
